{extend name="default/base/base_seller" /}
{block name="seller_btn"}
<a uri="{:url('Selleralbum/album_add')}" ds_type="dialog" dialog_title="{$Think.lang.album_class_add}" class="dssc-btn dssc-btn-green" style="right: 100px;">
    <i class="iconfont">&#xe728;</i>{$Think.lang.album_class_add}
</a>

{notempty name="aclass_info"}
<a id="open_uploader" href="JavaScript:void(0);" class="dssc-btn dssc-btn-acidblue"><i class="iconfont">&#xe733;</i>{$Think.lang.album_class_list_img_upload}</a>
<div class="upload-con" id="uploader" style="display: none;">
    <form method="post" action="" id="fileupload" enctype="multipart/form-data">
        <div class="upload-con-div">{$Think.lang.album_class_list_sel_img_class}{$Think.lang.ds_colon}
            <select name="category_id" id="category_id" class="select w80">
                {foreach name="aclass_info" item="v" }
                <option value='{$v.aclass_id}' class="w80">{$v.aclass_name}</option>
                {/foreach}
            </select>
        </div>
        <div class="upload-con-div">{$Think.lang.store_select_file}：
            <div class="dssc-upload-btn"> <a href="javascript:void(0);"><span>
                        <input type="file" hidefocus="true" size="1" class="input-file" name="file" multiple="multiple"/>
                    </span>
                    <p><i class="iconfont">&#xe733;</i>{$Think.lang.album_class_list_img_upload}</p>
                </a> </div>
        </div>
        <div dstype="file_msg"></div>
        <div class="upload-pmgressbar" dstype="file_loading"></div>
        <div class="upload-txt"><span>{$Think.lang.album_batch_upload_description}{$Think.config.ds_config.image_max_filesize}KB{$Think.lang.album_batch_upload_description_1}</span> </div>
    </form>
</div>
{/notempty}
{/block}
{block name="seller_main"}
<div id="pictureIndex" class="dssc-picture-folder">
        <table class="search-form">
            <tbody>
                <tr>
                    <td>&nbsp;</td>
                    <th>{$Think.lang.album_sort}</th>
                    <td class="w100">
                        <form name="select_sort" id="select_sort" class="sortord">
                            <select  name="sort" id="img_sort">
                                <option value="4" {if condition="$Request.param.sort eq '4'"}selected{/if}>{$Think.lang.album_sort_desc}</option>
                                <option value="5" {if condition="$Request.param.sort eq '5'"}selected{/if}>{$Think.lang.album_sort_asc}</option>
                                <option value="0" {if condition="$Request.param.sort eq '0'"}selected{/if}>{$Think.lang.album_sort_time_desc}</option>
                                <option value="1" {if condition="$Request.param.sort eq '1'"}selected{/if}>{$Think.lang.album_sort_time_asc}</option>
                                <option value="2" {if condition="$Request.param.sort eq '2'"}selected{/if}>{$Think.lang.album_sort_class_name_desc}</option>
                                <option value="3" {if condition="$Request.param.sort eq '3'"}selected{/if}>{$Think.lang.album_sort_class_name_asc}</option>
                            </select>
                        </form>
                    </td>
                </tr>
            </tbody>
        </table>
        {notempty name="aclass_info"}
        <div class="dssc-album">
            <ul>
                {foreach name="aclass_info" item="v" }
                <li class="hidden">
                    <dl>
                        <dt>
                        <div class="covers">
                            <a href="{:url('Selleralbum/album_pic_list',['id'=>$v.aclass_id])}">
                                {if $v.aclass_cover != ''}
                                <img id="aclass_cover" src="{:goods_cthumb($v['aclass_cover'], 240, session('store_id'))}">
                                {else /}
                                <i class="iconfont">&#xe6a2;</i>
                                {/if}
                            </a>
                        </div>
                        <h3 class="title"><a href="{:url('Selleralbum/album_pic_list',['id'=>$v.aclass_id])}">{$v.aclass_name}</a></h3>
                        </dt>
                        <dd class="buttons"><span ds_type="dialog" dialog_title="{$Think.lang.album_class_deit}" dialog_id='album_{$v.aclass_id}' dialog_width="480" uri="{:url('Selleralbum/album_edit',['id'=>$v.aclass_id])}"><a href="JavaScript:void(0);"><i class="iconfont">&#xe731;</i>{$Think.lang.album_class_edit}</a></span>
                            {if $v.aclass_isdefault != '1'}
                            <a href="javascript:void(0)" onclick="ds_ajaxget_confirm('{:url('Selleralbum/album_del',['id'=>$v.aclass_id])}','{$Think.lang.album_class_delete_confirm_message}');"><i class="iconfont">&#xe699;</i>{$Think.lang.album_class_delete}</a>
                            {/if}
                        </dd>
                    </dl>
                </li>
                {/foreach}
            </ul>
        </div>
        {else /}
        <div class="warning-option"><i class="iconfont">&#xe64c;&nbsp;</i><span>{$Think.lang.no_record}</span></div>
       {/notempty}
    </div>
    <script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/fileupload/jquery.iframe-transport.js" charset="utf-8"></script>
    <script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/fileupload/jquery.ui.widget.js" charset="utf-8"></script>
    <script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/fileupload/jquery.fileupload.js" charset="utf-8"></script>
<script type="text/javascript">

$(function() {
    //鼠标触及区域li改变class
    $(".dssc-album ul li").hover(function() {
        $(this).addClass("hover");
    }, function() {
        $(this).removeClass("hover");
    });
    
    // ajax 上传图片
    var upload_num = 0; // 上传图片成功数量
    var index=0
    $('#fileupload').fileupload({
        dataType: 'json',
        url: "{:url('Selleralbum/image_upload')}",
        formData: function(form){
            var aclass_id=$("#category_id").val()
            setTimeout(function(){
                index=0
            },1000)
            return [{name:'index',value:++index},{name:'category_id',value:aclass_id?aclass_id:0}];
        },
        add: function (e,data) {
        	$.each(data.files, function (index, file) {
                $('<div dstype="' + file.name.replace(/\./g, '_') + '"><p>'+ file.name +'</p><p class="loading"></p></div>').appendTo('div[dstype="file_loading"]');
            });
            data.submit();
        },
        done: function (e,data) {
            var param = data.result;
            $this = $('div[dstype="' + param.origin_file_name.replace(/\./g, '_') + '"]');
            $this.fadeOut(3000, function(){
                $(this).remove();
                if ($('div[dstype="file_loading"]').html() == '') {
                    setTimeout("window.location.reload()", 1000);
                }
            });
            if(param.state == 'true'){
                upload_num++;
                $('div[dstype="file_msg"]').html('<i class="iconfont">&#xe64d;</i>'+'{$Think.lang.album_upload_complete_one}'+upload_num+'{$Think.lang.album_upload_complete_two}');

            } else {
                $this.find('.loading').html(param.message).removeClass('loading');
            }
        }
    });

});

$(function(){
	$("#img_sort").change(function(){
		$('#select_sort').submit();
	});
});
</script>



{/block}

